﻿
Imports System.Runtime.CompilerServices
Imports osi.fs.property

Public Interface iproperty
    Function destroy() As eventComb
End Interface

Public Interface iproperty(Of T)
    Inherits iproperty
    'fail only if the data is not exist
    Function get_data(ByVal data As pointer(Of T)) As eventComb
    'never fail
    Function set_data(ByVal value As T) As eventComb
    'never fail
    Function get_set_data(ByVal d As _do(Of T, Boolean)) As eventComb
    'never fail
    Function get_set_data(ByVal d As get_set_data_d(Of T)) As eventComb
End Interface

Friend Module _property
    Public Function get_set_data_proxy(Of T)(ByVal d As _do(Of T, Boolean)) As get_set_data_d(Of T)
        Return Function(v As pointer(Of T)) As eventComb
                   Return New eventComb(Function() As Boolean
                                            Dim x As T = Nothing
                                            Return eva(x, +v) AndAlso
                                                   d(x) AndAlso
                                                   eva(v, x) AndAlso
                                                   goto_end()
                                        End Function)
               End Function
    End Function
End Module